package com.example.springbott.wx_controller;

import com.example.springbott.bean.BaseRespVo;
import com.example.springbott.bean.MarketComment;
import com.example.springbott.bean.common.CommonData;
import com.example.springbott.vo.WxCommentCount;
import com.example.springbott.vo.WxCommentList;
import com.example.springbott.wx_service.WxCommentService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 付常莹
 * @description: TODO
 * @date 2022/11/22 21:12
 * 该Controller用于小程序的评论模块
 */
@RestController
@RequestMapping("/wx/comment")
public class WxCommentController {
    @Resource
    WxCommentService wxCommentService;


    /**
     * 该方法用于用户添加评论，留言
     */
    @PostMapping("post")
    public BaseRespVo post(@RequestBody MarketComment marketComment){
      MarketComment marketComment1 =   wxCommentService.post(marketComment);
      return  BaseRespVo.ok(marketComment1);
    }


    /**
     * 该方法用于小程序模块，评论中的展示所有用户评论
     * @param valueId
     * @param type
     * @param showType
     * @param page
     * @param limit
     * @return
     */
    @GetMapping("list")
    public BaseRespVo list(Integer valueId,Integer type,Integer showType,Integer page,Integer limit){
        CommonData<WxCommentList> data = wxCommentService.list(valueId,type,showType,page,limit);
      return BaseRespVo.ok(data);
    }



    /**
     * 用于返回评论数量
     * @param valueId
     * @param type
     * @return
     */
    @GetMapping("count")
    public BaseRespVo count(Integer valueId,Integer type){
        WxCommentCount count1 = wxCommentService.count(valueId, type);
        return BaseRespVo.ok(count1);
    }

}
